﻿using System;
using DataScripter.Excel.Formatters;
using DataScripter.Excel.Formulas;

namespace DataScripter.Excel.FormattedValues
{
	class Date : BaseFormattedValue
	{
		private readonly DateTime? _value;
		private readonly Reference _cell;
		private readonly Formula _formula;

		public Date(DateTime? value) : this()
		{
			_value = value;
		}
		public Date(ICell cell) : this()
		{
			_cell = new Reference(cell);
		}
		public Date(Formula formula) : this()
		{
			_formula = formula;
		}

		private Date(): base(new DateFormatter())
		{}

		#region Implementation of IFormattedValue

		public override object Value
		{
			get { return (object) _value ?? _cell ?? _formula ; }
		}

		#endregion
	}
}